var mysql = require('mysql');

var conn = mysql.createConnection({
    host: '127.0.0.1',
    user: 'root',
    password: 'root',
    database: 'baike'
});

conn.connect(function(err) {
    if(err) throw err;
    console.log('connect success');
});

// 异步执行
conn.query('select * from bk_notice', function(err, result, fields) {
    if(err) {
        throw err;
    }
    console.log(result);
});

conn.end(function(err) {
    if(err) throw err;
    console.log('connect end');
});